import Vue from 'vue';
import App from './app';
import { router } from './router'
import { store } from './store'
import vpUI from './plugins';
import 'reset.css';
import 'animate.css';
import './assets/css/vp.css';
import './assets/font_m489hu8tsdbihpvi/iconfont.css';

import axios from 'axios';
import VueAxios from 'vue-axios'
import qs from 'qs';
import vueEventCalendar from 'vue-event-calendar'
import 'vue-event-calendar/dist/style.css' //1.1.10之后的版本，css被放在了单独的文件中，方便替换
import iosAlertView from 'vue-ios-alertview';
import { len12,len50 } from './plugins/assets/js/filter';
Vue.filter('len12', len12);
Vue.filter('len50', len50);

Vue.use(iosAlertView);

Vue.use(VueAxios, axios);
Vue.use(vpUI);
Vue.use(vueEventCalendar, {locale: 'en'}) //可以设置语言，支持中文和英文

axios.defaults.baseURL = 'http://vw.hnwcl.com/public/api';

Vue.mixin({
    methods: {
        locationHref (url) {
            this.$router.push(url);
        }
    }
})

//POST传参序列化
axios.interceptors.request.use((config) => {
    if(config.method  === 'post'){
        config.data = qs.stringify(config.data);
    }
    return config;
},(error) =>{
    alert("错误的传参");
    return Promise.reject(error);
});

axios.interceptors.response.use((res) =>{
    if(res.status != '200'){
        return Promise.reject(res);
    }
    return res.data;
}, (error) => {
    console.log("网络异常");
    return Promise.reject(error);
});

new Vue({
    el: '#app',
    router,
    store,
    render: h => h(App)
}).$mount('#main');
